test: zk dispute game factory and registry#19872
test: zk dispute game factory and registry#198720xChin wants to merge 25 commits intoethereum-optimism:developfrom
Conversation
| function setUp() public virtual override { | ||
| super.setUp(); | ||
|
|
||
| skipIfDevFeatureDisabled(DevFeatures.ZK_DISPUTE_GAME); |
There was a problem hiding this comment.
Every this is testes when zk dispute game is enabled. Maybe create one to check that reverts if the flag is disabled.
There was a problem hiding this comment.
With the flag disabled, the ZK game implementation wouldn't be deployed or registered in the factory so there's no zkGameProxy to test against. The ASR and factory are game-type agnostic; they don't check the feature flag themselves. The flag only gates deployment at the OPCM level, which is already covered by test_upgrade_enableZKGameWithoutDevFeature_reverts in the OPCM tests. At the ASR/factory level, "flag disabled" just means "no ZK game exists," which isn't a ZK-specific scenario worth testing here.
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
| /// @title DisputeGameFactory_ZkDisputeGame_TestInit | ||
| /// @notice Reusable test initialization for ZKDisputeGame factory tests. | ||
| abstract contract DisputeGameFactory_ZkDisputeGame_TestInit is DisputeGameFactory_TestInit { | ||
| IZKVerifier zkVerifier; |
There was a problem hiding this comment.
It's declared as a state var in TestInit because both _createZKGameWithParams (which sets it) and _assertZKGameCWIA (which reads it) live there. The alternative would be returning it from _createZKGameWithParams and passing it as an extra param to _assertZKGameCWIA, but I'd rather keep it this way
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol
Outdated
Show resolved
Hide resolved
0xOneTony
left a comment
There was a problem hiding this comment.
requesting changes above^
|
/ci authorize a651fe6 |
|
/ci authorize c41aa6f |
|
/ci authorize f64a2c6 |
|
/ci authorize 92e894d |
packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol
Outdated
Show resolved
Hide resolved
|
/ci authorize 1a786ef |
Summary
Adds ZK dispute game test coverage for
DisputeGameFactoryandAnchorStateRegistry, proving both contracts work correctly with the newZK_DISPUTE_GAMEtype (game type 10).Changes
DisputeGameFactory.t.solRestructuring:
_ZkDisputeGame_contractstest_create_implArgs_succeedsintoDisputeGameFactory_Create_FaultDisputeGame_Testfor explicit game-type separationDisputeGameFactory_ZkDisputeGame_TestInitabstract base with shared helpers (_createZKGame,_assertZKGameFactoryStorage,_assertZKGameCWIA)New test contracts:
DisputeGameFactory_Create_ZkDisputeGame_Test— create happy path, zero bond, wrong bond, no impl, duplicate UUIDDisputeGameFactory_SetImplementation_ZkDisputeGame_Test— impl+args storage, non-owner revertDisputeGameFactory_SetInitBond_ZkDisputeGame_Test— bond set/update, non-owner revertDisputeGameFactory_FindLatestGames_ZkDisputeGame_Test— multi-game orderingNew generic test:
testFuzz_create_overpayment_reverts— verifies factory rejects overpayment (sends more ETH than required bond)AnchorStateRegistry.t.solNew abstract base:
AnchorStateRegistry_ZkDisputeGame_TestInit— creates a real ZK game via factory, provides_mockZkGameAsValid()helperNew test contracts:
AnchorStateRegistry_SetAnchorState_ZkDisputeGame_Test— valid newer state, older game claim rejected, blacklisted, retired, challenger wins, not finalized (6 tests)AnchorStateRegistry_IsGameClaimValid_ZkDisputeGame_Test— valid claim, blacklisted, retired, not respected (4 tests)AnchorStateRegistry_IsGameProper_ZkDisputeGame_Test— all conditions met, blacklisted (2 tests)AnchorStateRegistry_BlacklistDisputeGame_ZkDisputeGame_Test— blacklist succeeds (1 test)Test plan
DEV_FEATURE__ZK_DISPUTE_GAME=true forge test --match-path test/dispute/DisputeGameFactory.t.solDEV_FEATURE__ZK_DISPUTE_GAME=true forge test --match-path test/dispute/AnchorStateRegistry.t.soljust pre-prpasses